

import vavava.util














if __name__ == '__main__':
    log = vavava.util.initlog("./log/223s.log")

    from sys import argv
    import os

    src_path = r'C:\Users\vavava\Desktop\PIL'
    src_path = r'D:\_code\trunk\python\Lib\pytesser_v0.0.1'
    src_path = r'c:\Python32\lib\site-packages\pillow-1.7.8-py2.7-win32.egg\PIL'
    src_path = r'D:\_code\tessercat\vs2008'
    desc_path = os.path.join(src_path,"out")

    argv_dic=vavava.util.parse_argvs(argv)
    if argv_dic:
        if argv_dic.get('-from'):  src_path = argv_dic.get('-from')
        if argv_dic.get('-to'):    desc_path =argv_dic.get('-to')

    file_list = os.listdir(src_path)
    vavava.util.assure_path(desc_path)

    src = {}
    desc = {}
    for f in file_list:
        if f.endswith('.py'):
            tmp1 = os.path.join(src_path,f)
            tmp2 = os.path.join(desc_path,f)
            src[f] = tmp1
            desc[f] = tmp2
            log.info(tmp1+"----"+tmp2)

    for f in src:
        tmp = r'C:\Python32\python.exe "C:\Python32\Tools\Scripts\2to3.py" "%s" -w "%s"'%(src[f],desc_path)
        log.info(tmp)
        os.system(tmp)
        #obj = compile(tmp,'','exec')
        #exec(obj)
